// room script file

bool useFancyIconbar = false;
bool iconbarVisible = false;

// Make sure you call this when you click a button on the iconbar and want to hide it.
function HideIconbar()
{	
	iconbarVisible = false;
	gIconbar.StopAllTweens();
	gIconbar.TweenTransparency(0.4, 100, eEaseOutTween, eNoBlockTween);
}
// Shows the iconbar with some tween action!
function ShowIconbar()
{
  gIconbar.SetPosition(0, -gIconbar.Height);
  gIconbar.Transparency = 100;
  iconbarVisible = true;
  
  gIconbar.StopAllTweens();
  gIconbar.TweenPosition(0.2, 0, 0, eEaseInEaseOutTween, eNoBlockTween);
  gIconbar.TweenTransparency(0.2, 0, eEaseInEaseOutTween, eNoBlockTween);
}

// Enter room (after fadein):
function room_AfterFadeIn()
{
  StartCutscene(eSkipESCOnly);
  
  player.Say("Welcome to Demo 3.");
  player.Say("Here we will demonstrate some GUI Tweens that hopefully can improve your GUIs.");
  player.Say("Like Room Objects and Characters, GUIs can both be tweened in Position and Transparency.");
  player.Say("You can also tween GUI elements like Labels, Lists, etc!");
  player.Say("Note that on the Tween script module header, you can customize whether GUI tweens are blocking or not by default.");
  player.Say("Let's tween the size:");
  
  int width = gStatusline.Width;
  int height = gStatusline.Height;
  
  gStatusline.TweenSize(2.0, 320, 200, eEaseOutTween, eBlockTween);
  gStatusline.TweenSize(2.0, 1, 1, eEaseInTween, eBlockTween);
  gStatusline.TweenSize(2.0, width, height, eEaseInEaseOutTween, eBlockTween);
  
  player.Say("Wasn't that fun?");
  player.Say("Now, here's what we're going to do:");
  player.Say("The default Iconbar in AGS is very stale.");
  player.Say("What if it could fade in while sliding down when putting the mouse over, and fades out when the mouse goes away?");
  player.Say("You could probably do it blocking with a Wait statement forcing the player to wait for the animation.");
  player.Say("That's annoying!");
  player.Say("How about this:");
  
  // Note that for this to work, you have to change the iconbar away from the "popup on mouse Y" mode.
  useFancyIconbar = true;
  Wait(SecondsToLoops(1.0));
  
  player.Say("Well, go ahead! Move your cursor up to the iconbar and see the difference.");
  player.Say("(This is the end of the demo, by the way, so enjoy that new iconbar.)");
  
  EndCutscene();
}

// Repeatedly execute:
function room_RepExec()
{
  // Normally, you would put this check on the global script repeatedly_execute function.
  if (useFancyIconbar)
  {
     if (mouse.y > gIconbar.Height && iconbarVisible)
    {
      HideIconbar();
    }
    
    if (mouse.y <= 13 && !gIconbar.Visible && !IsGamePaused())
    {		
      ShowIconbar();
    }
  }
}

function room_Load()
{
  gStatusline.Visible = true;
}

function room_Leave()
{
  gStatusline.Visible = false;
}
